package com.fay.designPattern.oop.basic;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @Title:
 * @Description:
 * @Author Fay Wang
 * @Date 2022/2/13 11:39
 * @Version 1.0
 */
public class ShoppingCart {
    private int itemsCount;
    private double totalPrice;
    private List<ShoppingCartItem> items = new ArrayList<>();

    public int getItemsCount() {
        return itemsCount;
    }

    public double getTotalPrice() {
        return totalPrice;
    }

    public List<ShoppingCartItem> getItems() {
        return Collections.unmodifiableList(this.items);
    }

    public void addItem(ShoppingCartItem item) {
        items.add(item);
        itemsCount++;
        totalPrice += item.getPrice();
    }

    public void clear() {
        items.clear();
        itemsCount = 0;
        totalPrice = 0.0;
    }


}


